import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkAnimalStartPage(Base):
    """
    车乐汇猜动物开始页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 关闭按钮
        self.animal_close_btn = (By.XPATH, Carpark.RESOURCE_ID.format("iv_close"))

        # 猜歌名标题
        self.animal_title_text = (By.XPATH, Carpark.RESOURCE_ID.format("tv_plugin_title"))

        # 猜歌名提示语
        self.animal_tip_text = (By.XPATH, Carpark.RESOURCE_ID.format("tv_plugin_sub_title"))

        # 猜歌名开始游戏
        self.animal_start_game_btn = (By.XPATH, Carpark.RESOURCE_ID.format("btn_plugin"))

        # 查看排行榜按钮
        self.animal_view_leaderboard_btn = (By.XPATH, Carpark.RESOURCE_ID.format("tv_sort"))

    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.animal_close_btn)

    def get_title(self):
        """
        获取猜动物标题

        :return:获取元素
        """
        return self.find_element_o(self.animal_title_text)

    def get_start_game(self):
        """
        获取猜动物开始游戏按钮文本

        :return:获取元素
        """
        return self.find_element_o(self.animal_start_game_btn)

    def get_tip(self):
        """
        获取猜动物提示

        :return:获取元素
        """
        return self.find_element_o(self.animal_tip_text)

    def click_start_game(self):
        """
         点击开始游戏

         :return:None
         """
        self.click_element(self.animal_start_game_btn)

    def click_view_leaderboard(self):
        """
         点击排行榜按钮

         :return:None
         """
        self.click_element(self.animal_view_leaderboard_btn)

    def is_display_carpark_start(self):
        """
        查看是否进入车乐汇猜动物开始页

        :return:
        """
        return self.is_display(self.animal_view_leaderboard_btn)
